using System;
using System.Collections.Generic;
using System.Text;

namespace My.IdlConverter.LoadManager
{
    public class AddinConfigStrategy : ConfigStrategy
    {
        public AddinConfigStrategy()
        {
        }

        public override void Makedisable()
        {
            UserComponent addin = Check<UserComponent>();

            if (addin.LoadBehavior == false)
                return;

            addin.LoadBehavior = false;
            ComponentLoader.Save(addin);
        }

        public override void Makeable()
        {
            UserComponent addin = Check<UserComponent>();

            if (addin.LoadBehavior == true)
                return;

            addin.LoadBehavior = true;
            ComponentLoader.Save(addin);
        }

        public override void Delete()
        {
            UserComponent addin = Check<UserComponent>();

            System.IO.FileInfo file = new System.IO.FileInfo(addin.CfgFile);
            if (file.Exists)
                file.MoveTo(String.Format("{0}__",addin.CfgFile));
        }
    }
}
